package com.youyoulong.framework.activiti.listener.event;

import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.event.ActivitiEvent;
import org.activiti.engine.delegate.event.ActivitiEventListener;
import org.apache.log4j.Logger;

public class MyListener implements ActivitiEventListener, org.activiti.engine.delegate.JavaDelegate
{
    private final Logger logger = Logger.getLogger(MyListener.class);
    
    @Override
    public void onEvent(ActivitiEvent event)
    {
        final String eventRefInfo = event.getEngineServices() + "#" + event.getProcessDefinitionId() + "#"
            + event.getProcessInstanceId() + "#" + event.getType()+",";
            
        switch (event.getType())
        {
            case JOB_EXECUTION_SUCCESS:
                logger.debug("A job well done!");
                break;
            case JOB_EXECUTION_FAILURE:
                logger.error(eventRefInfo + "A job has failed...");
                break;
            default:
                
                logger.debug("Event received【" + event.getProcessDefinitionId() + "】: " + event.getType());
        }
    }
    
    @Override
    public boolean isFailOnException()
    {
        // TODO Auto-generated method stub
       
        return false;
    }
    
    @Override
    public void execute(DelegateExecution execution)
        throws Exception
    {
        // TODO Auto-generated method stub
        
    }
    
}
